package com.rural.bus.driver.utils;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.logging.Logger;

import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateFormat;

public class DateUtil {
	
	//格式化未来时间---有今天、明天的描述
	public static String formatDiscriptionTime(long  date){
		String dateString ;
		long now = System.currentTimeMillis();
		int nowInt = getDayOfYear(now);
		int dateInt = getDayOfYear(date);
		SimpleDateFormat timeSdf = new SimpleDateFormat("HH:mm");
		SimpleDateFormat daySdf = new SimpleDateFormat("M月d日");
		switch (dateInt-nowInt) {
		case 0://今天
			dateString ="今天 "+timeSdf.format(date);
			break;
		case 1: //明天
			dateString ="明天 "+timeSdf.format(date);
			break;
		default:
			dateString = daySdf.format(date) +" "+ timeSdf.format(date);
			break;
		}
		return dateString;
		
	}
	
	private static int getDayOfYear(long time){
		Calendar cal = Calendar.getInstance();
		cal.setTime(new Date(time));
		return  cal.get(Calendar.DAY_OF_YEAR);  
	}
	
	public static String getTimeDistance(long second){
		StringBuffer sb = new StringBuffer();
		int hour = (int) (second/3600);
		if(hour != 0){
			sb.append(hour + "小时");
		}
		
		int minute = (int) ((second % 3600 ) / 60);
		sb.append(minute + "分钟");
		
		int seconds = (int)((second % 3600 ) % 60);
		sb.append(seconds + "秒");
		return sb.toString();
	}
	
}
